package com.sy.servlet;

import com.sy.service.TypeService;
import com.sy.service.impl.TypeServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;

@WebServlet("/types/*")
public class TypeServlet extends AbstractBaseServlet {
    private TypeService typeService = new TypeServiceImpl();

    @Override
    protected Object doService(String action, HttpServletRequest req, HttpServletResponse res) throws UnsupportedEncodingException {
        //如果是根据品牌查询车型
        if ("getByBrandId".equals(action)) {
            return typeService.getTypesByBrandId(paramToInt(req, "brandId"));
        }
        return null;
    }
}
